<template>
  <div class="permission-wrapper">
    <el-tabs v-model="activeName" type="card" @tab-click="handleChangeTab">
      <el-tab-pane label="成员权限" name="first">
        <el-aside>
          <el-tree
            :data="deptTreeData"
            :props="deptTreeProps"
            accordio
            node-key="id"
            default-expand-all
            >
          </el-tree>
        </el-aside>
        <el-main>
        </el-main>
      </el-tab-pane>
      <el-tab-pane label="权限模板" name="second">
        <el-row>
          <el-col>
            <el-button type="primary" >新建模板</el-button>
          </el-col>
        </el-row>
        <el-row>
          <el-table
            :key="tableKey"
            :data="list"
            v-loading="listLoading"
            element-loading-text="给我一点时间"
            border
            fit
            highlight-current-row
            style="width: 100%"
          >
            <el-table-column align="center" label="序号" width="80" fixed="left">
              <template slot-scope="scope">
                <span>{{scope.row.id}}</span>
              </template>
            </el-table-column>
            <el-table-column align="center" label="角色名称">
              <template slot-scope="scope">
                <span>{{scope.row.roleName}}</span>
              </template>
            </el-table-column>
            <el-table-column align="center" label="权限描述">
              <template slot-scope="scope">
                <span>{{scope.row.desc}}</span>
              </template>
            </el-table-column>
            <el-table-column align="center" label="操作" fixed="right" width="200">
              <template slot-scope="scope">
                <el-button size="small" type="primary">查看</el-button>
                <el-button size="small" type="warning">编辑</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-row>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import { mapGetters } from "vuex"
export default {
  name: 'PermissionIndex',
  data () {
    return {
      activeName: 'first',
      tableKey: 0,
      list: [
        {
          id: 1,
          roleName: '测试角色',
          desc: '测试权限'
        }
      ],
      listLoading: false,
      deptTreeData: [
        {
          label: '全部',
          children: [{
            label: '销售部',
            id: 2,
            level: 2
          },{
            label: '人事部',
            id: 3,
            level: 2
          },{
            label: '采购部',
            id: 4,
            level: 2
          },{
            label: '技术部',
            id: 5,
            level: 2
          },{
            label: '库房部',
            id: 6,
            level: 2
          },{
            label: '财务部',
            id: 7,
            level: 2,
            children: [
              {
                label: '子部门',
                id: 9,
                level: 3
              }
            ]
          }]
        }
      ],
      deptTreeProps: {
        children: 'children',
        label: 'label'
      }
    }
  },
  computed: {
    ...mapGetters(["permissions"])
  },
  created () {
  },
  methods: {
    handleChangeTab: function () {

    }
  }
}
</script>

<style scoped>
  .permission-wrapper {
    width: 100%;
    height: 100%;
    bottom: 10px;
    left: 0;
    right: 0;
    position: relative;
  }
  .el-row {
    margin-bottom: 20px;
  }
</style>
